
<html>
<head>
  <meta http-equiv=Content-Type content="text/html;charset=utf-8">
  <script type="text/javascript" src="jquery-1.9.1.js"></script>
		<script type="text/javascript">
		var url='127.0.0.1:8081/spring-websocket-demo';
		var wsurl='ws://'+url;
		var httpurl='http://'+url;
		function startWebSocket() {
		    if ('WebSocket' in window)
		        ws = new WebSocket(wsurl+"/websocket");
		    else if ('MozWebSocket' in window)
		        ws = new MozWebSocket(wsurl+"/websocket");
		    else
		        alert("not support");
		    
		    
		    ws.onmessage = function(evt) {
		        console.log(evt);
		       	alert(evt.data);
		    };
		    
		    ws.onclose = function(evt) {
		        
		    };
		    
		    ws.onopen = function(evt) {
		       
		    };
		}

		function sendMsg() {
		    var toName = document.getElementById('name').value;  //发给谁
		    ws.send(toName);
		}
		
		
		function pushs() {
            $.ajax({
                type: "POST",
                url: httpurl+"/push.do",
                datatype: "json",
                data: "param="+$("#param").val()+"&push="+$("#push").val(),
                success: function (data) {
                  
                }
            });
        }
		</script>
		</head>
		<body onload="startWebSocket();">
			注册设备
			<input type="text" id="name" value=""></input>
			<input type="button" value="send" onclick="sendMsg()"></input>
			</br>
			目标设备
			<input type="text" id="push" value=""></input>
			</br>
			推送信息
			<input type="text" name="param" id="param">
			<input type="button" onclick="pushs();" value="推送">
			
		</body>
		</html>